import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use( VueRouter )

const routes = [
  {
    path: "/",
    redirect: "/login"  //重定向到“/”。
  },
  {
    path: "/login",
    meta: { title: '登录' },
    component: () => import( "../views/LoginView.vue" )  // lazy，懒加载组件。
  },
  {
    path: "/main",
    name: 'main',
    meta: { reqiureAuth: true, title: '用户管理' }, //配置路由元信息
    component: () => import( "../views/MainView.vue" ),

  },
  // 这条路由的规则，必须写在最后。
  {
    path: "*",
    component: () => import( "../views/Page404.vue" )
  }
]

const router = new VueRouter( {
  mode: 'hash',
  routes
} )

export default router
